package com.qf.test;

import com.qf.service.UserService;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author 10537
 * @version V1.0
 * @Date 2021/9/28 20:47
 */

public class JDKDynamicProxy implements InvocationHandler {

    private UserService userService;

    public JDKDynamicProxy(UserService userService) {
        this.userService = userService;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        //记录日志
        System.out.println("记录日志");

        //执行原方法
        Object result=method.invoke(userService,args);

        return result;
    }
}
